require('babel-polyfill')
import Vue from 'vue'
import iView from 'iview'
import moment from 'moment'
import echarts from 'echarts'
import VueJsonp from 'vue-jsonp'
import VueTreeselect from '@riophae/vue-treeselect'
import VTooltip from 'v-tooltip'
import App from './components/App'
import router from './router'
import store from './store/store'
import permission from '@/utils/permission'
import 'font-awesome/css/font-awesome.min.css'
import '@/assets/font/font.scss'
import 'iview/dist/styles/iview.css'
import '@/assets/style/reset.scss'
import '@/assets/style/layout.scss'
import '@/assets/style/pages.scss'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import '@/assets/style/media.scss'
import '@/styles/dashboard.scss'
import Notice from './components/Notice/index'
import Alarm from './components/Alarm/index'
import '@/icons/index'
import flexible from '@/utils/flexible'

flexible()

Vue.use(Notice)
Vue.use(Alarm)
Vue.use(VTooltip)
Vue.use(VueJsonp, 5000)
const ENV = process.env.NODE_ENV
Vue.config.silent = ENV != 'productioin'

Vue.use(iView, {
  transfer: true,
  size: 'default'
})

Vue.component('Treeselect', VueTreeselect)

moment.locale('zh-cn')
Vue.prototype.moment = moment

Vue.prototype.echarts = echarts

iView.LoadingBar.config({
  color: '#fff'
})

router.beforeEach((to, from, next) => {
  iView.LoadingBar.start()
  permission(to, from, next, store, router)
})

router.afterEach(() => {
  iView.LoadingBar.finish()
  window.scrollTo(0, 0)
})

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
